<?php

namespace App\Admin\Product;

if (!defined('IN_PX'))
    exit;

use App\Admin\AbstractCommon;
use App\Model;

/**
 * 内容页
 */
class Content extends AbstractCommon {

    private function __Controller() {}

    //private function __Route($value = '/structure') {}
    protected function __Inject($db) {}

    public function productContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('a.*, ars.*')
                ->table('`#@__@archives` a, `#@__@archives_substance` ars')
                ->where('a.`archives_id` = ? AND a.`archives_id` = ars.`archives_id`')
                ->bind(array($_GET['id']))
                ->find();
        }
        if (!isset($_GET['parentId'])){
            $_GET['parentId'] = '';
        }
        if (!isset($_GET['id'])) {
            $_GET['id'] = '';
        }
        $this->sltIDTree = $this->_selectIDTree(array('table' => '`#@__@category`',
            'where' => '`is_display` = 1 AND (`root_id` = 31 || `root_id` = 56)'),
            array('value' => 'category_id', 'text' => 'category_name',
                'selected' => $this->rs ? $this->rs->category_id : $_GET['parentId']),
            array('disabled' => $this->pageControl));
        $this->getSort = $this->_getSort('archives');

        $this->banners= $this->db->select('`src`, `src_title`')
            ->table('`#@__@archives_attach`')
            ->where('`archives_id` = ?')
            ->bind(array($_GET['id']))
            ->findAll();
        $this->banners = json_encode($this->banners);

        return true;
    }
    
}
